hackerrank time complexity Primality solution